{% extends "one_column_body.html" %}
{% import "macros.html" as macros %}
<!-- complete.html -->
{#
views calling this template: 
* django_authopenid.views.register with login_type='openid'
* django_authopenid.views.signin - with login_type='legacy'

purpose of this template is to allow user enter his/her name
email and sign up for email alerts at the initial registratio

parameters:
* provider 
* login_type openid|legacy
* username (same as screen name or username in the models, and nickname in openid sreg)
* openid_register_form
* openid_verify_form - not clear what this form is supposed to do, not used for legacy
* openid_username_exists
#}
{% block head %}{% endblock %}
{% block title %}{% spaceless %}{% trans %}Complete registration{% endtrans %}{% endspaceless %}{% endblock %}
{% block body_class %}registration-page{% endblock %}
{% block content %}
<div class="flip-tabs">
    <div class="login complete-registration flip-content flip-content-active">
        {% if settings.NEW_REGISTRATIONS_DISABLED %}
            <h1 class="section-title">{% trans %}New user registrations are disabled{% endtrans %}</h1>
            <div>{{ settings.NEW_REGISTRATIONS_DISABLED_MESSAGE }}</div>
        {% else %}
            <h1 class="section-title">{% trans %}Complete registration{% endtrans %}</h1>
            {% if openid_register_form.errors %}
                <ul class="errorlist">
                {% for error in openid_register_form.non_field_errors() %}
                    <li>{{ error }}</li>
                {% endfor %}
                </ul>
            {% endif %}
            <form 
                id="register-form"
                name="fregister" 
                {% if login_type=='openid' %}
                    action="{% url user_register %}"
                {% elif login_type=='facebook' %}
                    action=""
                {% else %}
                    action="{{ default_form_action }}"
                {% endif %}
                method="POST"
            >{% csrf_token %}
                {{ openid_register_form.next }}
                <div class="form-group">
                    {% if openid_register_form.username.errors %} 
                        <p class="error">{{ openid_register_form.username.errors|join(", ") }}</p>
                    {% endif %}
                    <input class="required login" id="id_username" 
                        maxlength="255" name="username" tabindex="0" type="text"
                        {% if openid_register_form.username.value() %}
                            value="{{ openid_register_form.username.value()|escape }}"
                        {% endif %}
                        placeholder="{% trans %}Choose a screen name{% endtrans %}"
                    >
                </div>
                <div class="form-group">
                    {% if openid_register_form.email.errors %} 
                        <p class="error">{{ openid_register_form.email.errors|join(", ") }}</p>
                    {% endif %}
                    <input class="required login" id="id_email" maxlength="200" 
                        name="email" type="text"
                        {% if openid_register_form.email.value() %}
                            value="{{ openid_register_form.email.value()|escape }}"
                        {% endif %}
                        placeholder="{% trans %}Email address{% endtrans %}"
                    >
                </div>
                {% set tos_field = openid_register_form.terms_accepted %}
                {% include "authopenid/tos_field.html" %}

                {% if openid_register_form.recaptcha %}
                <div class="form-row-vertical">
                    {{ macros.form_field_with_errors(openid_register_form.recaptcha ) }}
                </div>
                {% endif %}
                <div class="submit-row">
                    <input 
                        id="register-button"
                        type="submit"
                        name="bnewaccount"
                        value="{% trans %}Signup{% endtrans %}"
                    />
                </div>
            </form>
        {% endif %}
    </div>
    <div class="recover-account flip-content">
        <h1 class="section-title">{% trans %}Recover account{% endtrans %}</h1>
        {% include "authopenid/account_recovery_form.html" %}
    </div>
    <div class="flip-tab-controls">
        <p class="flip-tab flip-tab-active" data-target=".recover-account">
            <strong>{% trans %}Already have an account?{% endtrans %}</strong>
            <a class="trigger">{% trans %}Recover it by email.{% endtrans %}</a>
        </p>
        <p class="flip-tab" data-target=".complete-registration">
            <strong>{% trans %}Prefer to create a new account?{% endtrans %}</strong>
            <a class="trigger">{% trans %}Return to registration.{% endtrans %}</a>
        </p>
    </div>
</div>
{% endblock %}
<!-- end complete.html -->
{% block endjs %}
    <script type="text/javascript">
        $('#id_username').focus();
    </script>
    <script type="text/javascript" src="{{ '/js/utils/flip_tabs.js'|media }}"></script>
    {{ macros.one_shot_form_js(form="#register-form", submit_button="#register-button") }}
{% endblock %}
